<!--  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml"> -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>留言列表</title>
</head>

<body>
<?php 
function row_color($i)
{
	$bgcolor1 = "#CCCCCC";

	if ( ($i % 2) == 0 ) {
		return $bgcolor1;
	} 
}
	require_once 'dbconn.php';
	/**************分页显示****************/
	$page=$_GET['page'];
	if ($page==''){
	$page=1;
	}
	$page_size=10;

	$sql = "select * from post order by ptime desc";
    $result = $db->sql_query($sql);
    $rowset = $db->sql_fetchrowset($result);
    $total=0;
    ?>
<table width="100%" boder="0" cellspacing="0" cellpadding="0" style="margin-left:15px" style="margin-right:10px">
<tr>
<td height="30"><h2><b>留言列表：</b></h2></td>
</tr>
<tr>
<td height="20"></td>
</tr>
<?php 
    foreach ($rowset as $row){
	  		$total++;	
    }
    $page_count=ceil($total/$page_size);
    $offset=($page-1)*$page_size;       //计算下一页从第几条数据开始循环
    $sql="select * from post order by ptime desc limit $page_size offset $offset";
    $result = $db->sql_query($sql);
    $rowset = $db->sql_fetchrowset($result);
    $i=$offset;

    foreach ($rowset as $key=>$row){
   		$i++;   
		print "<tr bgcolor=\"".row_color($i)."\">\n";
?>
<td height="30" style="border-bottom:1px dashed #000000;">
		<?php echo "&nbsp;".$i.".&nbsp;";?> 
  		<a href="msgreply_bslist.php?postid=<?php echo $row["postid"]?>"</a>
  		<?php echo $row["ptitle"]."<br>";?>
</td>
<td align="right" style="border-bottom:1px dashed #000000;">
<a href="delmsg.php?postid=<?php echo $row["postid"]?>" onclick="return checkagain();">[删除]</a>&nbsp;&nbsp;&nbsp;
</td>
</tr>
<?php 			
	}
?>
</table> 
<table width="100%" border="0" cellspacing="2" cellpadding="0">
<tr>
<td height="10"></td>
</tr>
<tr>
<!-- 分页-->
  <td width="40%">&nbsp;&nbsp;页次:<?php echo $page;?>/<?php echo $page_count;?>页&nbsp;&nbsp;&nbsp;记录共:<?php echo $total;?>条&nbsp;</td>
  <td align="right">
    <?php 
    if ($page!=1) {
    	echo "<a href=msgboard_bslist.php?page=1>首页</a>&nbsp;";
    	echo "<a href=msgboard_bslist.php?page=".($page-1).">上一页</a>&nbsp;";
    }
    if ($page<$page_count) {
    	echo "<a href=msgboard_bslist.php?page=".($page+1).">下一页</a>&nbsp;";
    	echo "<a href=msgboard_bslist.php?page=".$page_count.">尾页</a>";
    }
    $db->sql_freeresult($result);
    ?>
  </td>
</tr>
</table>
</body>
</html>
<!-- 删除记录前确认 -->
<script language='javascript'>
function checkagain(){
	if(confirm('确实要删除此留言信息吗？')) 
		return true;
	else 
		return false; 
}
</script>